package cn.iocoder.yudao.module.design.dal.mysql.notes;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.notes.vo.NotesExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.notes.vo.NotesPageReqVO;
import cn.iocoder.yudao.module.design.dal.dataobject.notes.NotesDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 项目笔记 Mapper
 *
 * @author czw
 */
@Mapper
public interface NotesMapper extends BaseMapperX<NotesDO> {

    default PageResult<NotesDO> selectPage(NotesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NotesDO>()
                .betweenIfPresent(NotesDO::getDate, reqVO.getDate())
                .eqIfPresent(NotesDO::getHouseId, reqVO.getHouseId())
                .eqIfPresent(NotesDO::getFlowId, reqVO.getFlowId())
                .eqIfPresent(NotesDO::getNodeId, reqVO.getNodeId())
                .likeIfPresent(NotesDO::getContent, reqVO.getContent())
                .eqIfPresent(NotesDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(NotesDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(NotesDO::getImgUrl, reqVO.getImgUrl())
                .eqIfPresent(NotesDO::getStatusCd, reqVO.getStatusCd())
                .eqIfPresent(NotesDO::getRemark, reqVO.getRemark())
                .likeIfPresent(NotesDO::getTitle, reqVO.getTitle())
                .orderByDesc(NotesDO::getId));
    }

    default List<NotesDO> selectList(NotesExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<NotesDO>()
                .betweenIfPresent(NotesDO::getDate, reqVO.getDate())
                .eqIfPresent(NotesDO::getHouseId, reqVO.getHouseId())
                .eqIfPresent(NotesDO::getFlowId, reqVO.getFlowId())
                .eqIfPresent(NotesDO::getNodeId, reqVO.getNodeId())
                .eqIfPresent(NotesDO::getContent, reqVO.getContent())
                .eqIfPresent(NotesDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(NotesDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(NotesDO::getImgUrl, reqVO.getImgUrl())
                .eqIfPresent(NotesDO::getStatusCd, reqVO.getStatusCd())
                .eqIfPresent(NotesDO::getRemark, reqVO.getRemark())
                .eqIfPresent(NotesDO::getTitle, reqVO.getTitle())
                .orderByDesc(NotesDO::getId));
    }

}
